<template>
  <!-- 容器 -->
  <div class="charts" ref="charts"></div>
</template>

<script>
import { mapState } from 'vuex'
//引入echarts
import * as echarts from 'echarts'
export default {
  name: '',
  data() {
    return {
      barCharts: null
    }
  },
  computed: {
    ...mapState({
      listState: (state) => state.Home.list
    })
  },
  watch: {
    listState() {
      this.barCharts.setOption({
        xAxis: {
          //隐藏x轴
          show: false,
          //均分
          type: 'category'
        },
        yAxis: {
          //隐藏y轴
          show: false
        },
        //系列
        series: [
          {
            //图标形式-柱状图
            type: 'bar',
            data: this.listState.payTrend,
            color: 'skyblue'
          }
        ],
        //布局调试
        grid: {
          left: 0,
          top: 0,
          right: 0,
          bottom: 0
        },
        tooltip: {}
      })
    }
  },
  mounted() {
    //初始化echarts实例
    this.barCharts = echarts.init(this.$refs.charts)
    //配置数据
  }
}
</script>

<style scoped>
.charts {
  width: 100%;
  height: 100%;
}
</style>
